import { NCode } from 'naive-ui'
import type { CodeProps } from "naive-ui";
import type { HTMLAttributes } from "vue";

export type CodeFactoryConstructorType = {
    props?: CodeProps,
    attrs?: HTMLAttributes
}

export class CodeFactory {
    private attrs: HTMLAttributes = {}
    private props: CodeProps = {}

    constructor(data?: CodeFactoryConstructorType) {
        if (data?.props) this.setProps(data.props);
        if (data?.attrs) this.setAttrs(data.attrs);
    }

    setProps(props: CodeProps) {
        this.props = props
        return this
    }

    setAttrs(attrs: HTMLAttributes) {
        this.attrs = attrs
        return this
    }
    create() {
        return <NCode {...this.attrs} {...this.props}></NCode>
    }
}